#!/bin/bash
echo "hello, world 大师傅似" > origin.txt
for cipher in des aes rc6; do
    for mode in ecb cbc cfb ofb; do
        echo h | ./test1 $cipher $mode origin.txt cipher.txt>>tmp.tmp
        echo h | ./test1 -d $cipher $mode cipher.txt decipher.txt>>tmp.tmp
        result=$(diff origin.txt decipher.txt -q)
        if test -z "$result" 
        then
        echo "$cipher 算法 $mode 模式测试通过"
        else
        echo "$cipher 算法 $mode 模式测试未通过"
        fi
    done
done
echo h | ./test1 rc4 none origin.txt cipher.txt >> tmp.tmp
echo h | ./test1 -d rc4 none cipher.txt decipher.txt >> tmp.tmp
result=$(diff origin.txt decipher.txt -q)
if test -z "$result" 
then
echo "rc4 算法测试通过"
else
echo "rc4 算法测试未通过"
fi